package com.sikaryofficial.system.api.factory;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.RemoteUserDailyService;
import com.sikaryofficial.system.api.model.ManualExportReq;
import com.sikaryofficial.system.api.model.user.UserDailyDTO;
import com.sikaryofficial.system.api.model.user.UserRegisterDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author : qinjinyuan
 * @desc : TODO  请填写你的功能描述
 * @date : 2025/03/21 15:45
 */
public class RemoteUserDailyFallbackFactory implements FallbackFactory<RemoteUserDailyService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserDailyFallbackFactory.class);

    @Override
    public RemoteUserDailyService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteUserDailyService() {
            /**
             * 根据时间段查询时间范围内的注册用户
             *
             * @param req
             * @return 结果
             */
            @Override
            public R<List<UserRegisterDTO>> queryRegisterDailyByTime(ManualExportReq req) {
                return R.fail("queryRegisterDailyByTime fail:" + throwable.getMessage());
            }

            /**
             * 根据时间段查询时间范围内的日活用户
             *
             * @param req
             * @return 结果
             */
            @Override
            public R<List<UserDailyDTO>> queryDailyByTime(ManualExportReq req) {
                return R.fail("queryDailyByTime fail:" + throwable.getMessage());
            }
        };
    }
}
